package com.rem.designPattern.flyweight享元;

import java.util.HashMap;

/**
 * 享元模式
 * 运用共享技术有效地支持大量细粒度的对象
 * <p>
 * 很多用户浏览网站，网站的类型和内容是固定的
 *
 * @author Rem
 * @date 2022-11-18
 */
public class WebsiteFactory {
    private static final HashMap<String, ConcreteWebsite> POOL = new HashMap<>();

    public static Website getWebsiteCategory(Type type) {
        if (POOL.get(String.valueOf(type)) == null) {
            POOL.put(String.valueOf(type), new ConcreteWebsite(type));
        }
        return POOL.get(String.valueOf(type));
    }

    public static Integer getSize() {
        return POOL.size();
    }
}